<?php
/* --------------------------------------------------------------
   campaigns_ip_table_update.php 2023-03-01
   Gambio GmbH
   http://www.gambio.de
   Copyright (c) 2023 Gambio GmbH
   Released under the GNU General Public License (Version 2)
   [http://www.gnu.org/licenses/gpl-2.0.html]
   -------------------------------------------------------------
*/

/** @var DatabaseModel $this */
/** @var int $t_success */

if (!$this->columnExists('campaigns_ip', 'id')) {
    $query     = 'ALTER TABLE `campaigns_ip` ADD `id` INT NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)';
    $t_success &= $this->query($query);
}

if (!$this->indexExists('campaigns_ip', 'INDEX', ['campaign', 'time'])) {
    $this->set_index('campaigns_ip', 'INDEX', ['campaign', 'time'], 'campaign');
}
